import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 自建的全局样式表
import './assets/css/global.css'
// 阿里巴巴矢量图,login表单图标
import './assets/font_1738972_g3vmfb94tbs/iconfont.css'
// 导入vue-tree插件
import ZkTable from 'vue-table-with-tree-grid'
//导入富文本编辑器组件
import VueQuillEditor from 'vue-quill-editor'
//导入富文本编辑器css样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
//导入NProgress包对应的js和css
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
//导入axios
import axios from 'axios'
//配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//将axios挂载到原型上面
Vue.prototype.$http = axios
//axios请求拦截
axios.interceptors.request.use(config => {
  //为请求头对象，添加token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  //进度条
  NProgress.start()
  return config
})
axios.interceptors.response.use(config => {
  //进度条
  NProgress.done()
  //在最后必须return config
  return config
})
// 手动注册vue-tree插件，此插件改名为tree-table
Vue.component('tree-table', ZkTable)
//全局注册富文本编辑器插件
Vue.use(VueQuillEditor)

Vue.config.productionTip = false
// 全局定义过滤器
Vue.filter('timeFormat', function(value) {
  const dt = new Date(value)
  const y = dt.getFullYear() //获取完整的年份(4位,1970-????)
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const h = (dt.getHours() + '').padStart(2, '0')
  const mi = (dt.getMinutes() + '').padStart(2, '0')
  const s = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${h}:${mi}:${s}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
// import App from './App'
// new Vue({
//     el: '#root',
//     template: '<App></App>',
//     components: {
//         App
//     }
// })
